/* ///////////////////////////////////////////////////////////////  */
/*  Program : tool.c                                                */
/* ---------------------------------------------------------------  */
/*  This is a set of sample C files for the UML diagram homework.   */
/*                                                                  */
/*  The program is written for the class "Introduction to Computer  */
/*  Science" by Hung-Cheng Su on 04/30/2012.                        */
/* //////////////////////////////////////////////////////////////// */
#include <string.h>
#include "tool.h"

void swap_char(void *a, void *b)
{
    char  **src = (char **) a;
    char  **dec = (char **) b;
    char   *temp;
    temp = *src;
    *src = *dec;
    *dec = temp;
}

void swap_int(void *a, void *b)
{
    long    temp;
    long   *src = (long *) a;
    long   *dec = (long *) b;
    temp = *src;
    *src = *dec;
    *dec = temp;
}

int cmp_char(void *a, void *b)
{
    char  **src = (char **) a;
    char  **dec = (char **) b;
    return strcmp(*src, *dec);
}

int cmp_int(void *a, void *b)
{
    long   *src = (long *) a;
    long   *dec = (long *) b;
    return (*src > *dec) ? 1 : ((*src < *dec) ? -1 : 0);
}
